package com.bluedot.bank.dao.user;


import org.hibernate.Query;
import org.hibernate.Session;

import com.bluedot.bank.dao.HibernateDaoSupport;
import com.bluedot.bank.dao.Pagination;
import com.bluedot.bank.dao.customer.CustomerConditons;

public class UserDaoImpl extends HibernateDaoSupport<User, Long> implements UserDao {

	public UserDaoImpl(){
		this.entityClass=User.class;
	}

	@Override
	public User findByName(String userName) {
		Session session=this.getSession();
		Query query=session.createQuery("from " + User.class.getName()+" u where u.userName = :keyword");
		query.setParameter("keyword", userName);
		User user=(User)query.uniqueResult();
		return user;
	}
	@Override
	public void browse(Pagination<User> pagination) {
		CustomerConditons f=(CustomerConditons)pagination.getConditon();
		if(f!=null)
		{
			this.getSession().enableFilter(f.getFilterName()).setParameter(f.getKey(), f.getO());
		}
		super.browse(pagination);
	}

}
